package cn.com.visionsky.bocsz.bda.webservice.handler.cst_lbl_ast_query;

import cn.com.visionsky.bocsz.bda.webservice.Constants;
import cn.com.visionsky.bocsz.bda.webservice.cache.FieldPermissionsCache;
import cn.com.visionsky.bocsz.bda.webservice.handler.Handler;
import cn.com.visionsky.bocsz.bda.webservice.permission.CstLblAstTags;
import cn.com.visionsky.bocsz.bda.webservice.ws.FullTextUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.hadoop.hbase.HbaseTemplate;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by heweifeng on 2018/12/25.
 */
@Component
public class CstLblAstQueryHandler implements Handler {
    private static final Logger logger = LoggerFactory.getLogger(CstLblAstQueryHandler.class);

    public static final String TABLE_CST_LBL_AST = "CST_LBL_AST";

    public static final String separator = ",";

    @Autowired
    private HbaseTemplate hbaseTemplate;


    @Override
    public String handle(String fullTextRequestStr, HttpServletRequest request) {
        logger.info(String.format("fullTextRequestStr: %s", fullTextRequestStr));

        List<String> ctfNoList = new ArrayList<String>(); //证件号

        FullTextRequest fullTextRequest = FullTextUtils.getFullTextRequest(FullTextRequest.class, fullTextRequestStr);

        String ctfNo = fullTextRequest.getCtfNo().trim();
        if (ctfNo.contains(separator)) {
            String[] ctfNoArray = ctfNo.split(separator);
            for (String element : ctfNoArray) {
                if (StringUtils.isNotBlank(element)) {
                    ctfNoList.add(element.trim());
                }
            }
        } else {
            ctfNoList.add(ctfNo);
        }

        //查询结果
        List<CstLblAstInfo> allResultList = null;
        if (!ctfNoList.isEmpty()) {
            String clientIp = request.getRemoteAddr();
            String key = clientIp + Constants.CST_LBL_AST_QUERY_MODULE.toUpperCase();
            //查询授权字段
            Map<String, List<String>> fieldPermissionsCacheMap = FieldPermissionsCache.getFieldPermissionsCacheMap();

            List<String> authorizationFieldList = fieldPermissionsCacheMap.get(key);
            if (authorizationFieldList != null && !authorizationFieldList.isEmpty()) {
                //识别客户端请求的字段
                CstLblAstTags cstLblAstTags = new CstLblAstTags(fullTextRequest);
                List<String> requestedFieldList = cstLblAstTags.discernRequestedField();
                allResultList = scanTable(TABLE_CST_LBL_AST, ctfNoList, authorizationFieldList, fullTextRequest, requestedFieldList);
                logger.info("Cst Lbl Ast Query Module Result List Size:" + allResultList.size());
            }
        }
        final FullTextResponse fullTextResponse = new FullTextResponse();
        fullTextResponse.setCstLblAstInfoList(allResultList);
        return FullTextUtils.getFullTextResponseStr(fullTextResponse);
    }

    private List<CstLblAstInfo> scanTable(String tableName, List<String> ctfNoList, List<String> authorizationFieldList, FullTextRequest fullTextRequest, List<String> requestedFieldList) {
        List<CstLblAstInfo> resultList = new ArrayList<CstLblAstInfo>();
        Result[] results = getResultArray(tableName, ctfNoList);// 直接查getList(Get)
        if (results != null) {
            for (Result result : results) {//对返回的结果集进行操作//行操作
                Map<String, String> resultMap = new HashMap<String, String>();
                for (Cell cell : result.rawCells()) {
                    if (cell != null) {
                        String key = Bytes.toString(CellUtil.cloneQualifier(cell));
                        String value = Bytes.toString(CellUtil.cloneValue(cell));
                        resultMap.put(key, value);
                    }
                }
                CstLblAstInfo cstLblAstInfo = setValue(resultMap, authorizationFieldList, fullTextRequest.getQueryField());
                if (StringUtils.isNotBlank(cstLblAstInfo.getNewCtfNo())) {
                    resultList.add(cstLblAstInfo);
                }
            }
        }
        return resultList;
    }


    private CstLblAstInfo setValue(Map<String, String> resultMap, List<String> authorizationFieldList, String queryField) {
        CstLblAstInfo cstLblAstInfo = new CstLblAstInfo();
        if (authorizationFieldList != null && !authorizationFieldList.isEmpty()) {
            final int ONE_RESULT = 1;
            final String ALL_FIELD = "*";
            if (authorizationFieldList.size() == ONE_RESULT) {
                if (authorizationFieldList.contains(ALL_FIELD)) {
                    List<String> allFieldList = new ArrayList<String>();

                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_ETL_DATE); //处理日期
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_NEW_CTF_NO); //新证件号
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_AVA_CST); //是否有效客户(0-否;1-是)
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BR_M); //理财、消贷、开柜经理归属行
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BR_A); //金融资产口径归属行
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BR_C); //信用卡口径归属行
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BR_D); //消贷口径归属行
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_A); //金融资产合计
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_C); //信用卡余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_D); //消贷余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_LVL_A); //金融资产口径客户层级
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_LVL_C); //信用卡口客户层级
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_LVL_D); //消贷口径客户层级
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_LVL); //客户层级(1-私人银行2-财富管理3-中银理财24-中银理财15-潜力客户6-基础客户)
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_LVL_MAX); //客户层级(1-私人银行2-财富管理3-理财客户5-潜力客户6-基础客户)
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_LVL_SRC); //客户层级来源(A-金融资产口径;D-消贷口径;C-信用卡口径)
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_LVL_BR); //归属行
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_LVL_MAX_BR); //最大化归属行
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_SAVING); //存款余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_HQ_CNY); //人民币活期存款余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_HQ_RMB); //外币活期存款余额(折人民币)
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_DQ_CNY); //人民币定期期存款余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_DQ_RMB); //外币定期存款余额(折人民币)
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_CARD_GJJ); //公积金借记卡余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_CHECK); //支票余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_VOUCHER_BOND); //凭证式国债余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_SAVING_BOND); //储蓄式国债余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_BOOKING_BOND); //记账式国债余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND); //基金余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_PGX); //偏股型基金余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_ZQX); //债券型基金余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_HBX); //货币型基金余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_YDD); //一对多基金余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_OTH); //其他基金余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_INS); //保险余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_V_ACCOUNT); //V账户余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD); //理财余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_CNY); //人民币理财余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_RMB); //外币理财余额（折人民币）
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_BN); //表内理财余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_BW); //表外理财余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_H); //持有高收益理财产品余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_M); //持有中收益理财产品余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_L); //持有低收益理财产品余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_NONLVL); //持有收益类型未分类的理财产品余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_GOLD); //纸黄金余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_SILVER); //纸白银余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_JOIN_XPAD); //汇聚理财余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_XPAD); //通过基金系统销售的理财余额
                    allFieldList.add(Constants.CST_LBL_AST_QUERY_MODULE_BAL_TPCC); //第三方存管余额

                    authorizationFieldList = allFieldList;
                }
            }
            if (StringUtils.isNotBlank(queryField)) {//表示需要进一步缩小查询字段范围
                List<String> queryFieldList = new ArrayList<String>();
                if (queryField.contains(separator)) {//包含分隔符
                    String[] queryFieldArray = queryField.split(separator);
                    for (String element : queryFieldArray) {
                        if (StringUtils.isNotBlank(element)) {
                            queryFieldList.add(element.trim().toUpperCase());
                        }
                    }
                } else {
                    queryFieldList.add(queryField.trim().toUpperCase());
                }
                authorizationFieldList = queryFieldList;
            }
            //返回允许查看字段
            for (String authorizationFiel : authorizationFieldList) {
                switch (authorizationFiel) {
                    case Constants.CST_LBL_AST_QUERY_MODULE_ETL_DATE:
                        //处理日期
                        cstLblAstInfo.setEtlDate(resultMap.get(authorizationFiel));
                        break;
                      /*
                    case Constants.CST_LBL_AST_QUERY_MODULE_NEW_CTF_NO:
                        cstLblAstInfo.setNewCtfNo(resultMap.get(authorizationFiel));
                        break;
                       */
                    case Constants.CST_LBL_AST_QUERY_MODULE_AVA_CST:
                        //是否有效客户
                        cstLblAstInfo.setAvaCst(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BR_M:
                        //理财、消贷、开柜经理归属行
                        cstLblAstInfo.setBrM(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BR_A:
                        //金融资产口径归属行
                        cstLblAstInfo.setBrA(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BR_C:
                        //信用卡口径归属行
                        cstLblAstInfo.setBrC(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BR_D:
                        //消贷口径归属行
                        cstLblAstInfo.setBrD(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_A:
                        //金融资产合计
                        cstLblAstInfo.setBalA(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_C:
                        //信用卡余额
                        cstLblAstInfo.setBalC(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_D:
                        //消贷余额
                        cstLblAstInfo.setBalD(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_LVL_A:
                        //金融资产口径客户层级
                        cstLblAstInfo.setLvlA(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_LVL_C:
                        //信用卡口客户层级
                        cstLblAstInfo.setLvlC(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_LVL_D:
                        //消贷口径客户层级
                        cstLblAstInfo.setLvlD(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_LVL:
                        //客户层级(1-私人银行2-财富管理3-中银理财24-中银理财15-潜力客户6-基础客户)
                        cstLblAstInfo.setLvl(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_LVL_MAX:
                        //客户层级(1-私人银行2-财富管理3-理财客户5-潜力客户6-基础客户)
                        cstLblAstInfo.setLvlMax(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_LVL_SRC:
                        //客户层级来源(A-金融资产口径;D-消贷口径;C-信用卡口径)
                        cstLblAstInfo.setLvlSrc(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_LVL_BR:
                        //归属行
                        cstLblAstInfo.setLvlBr(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_LVL_MAX_BR:
                        //最大化归属行
                        cstLblAstInfo.setLvl_max_br(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_SAVING:
                        //存款余额
                        cstLblAstInfo.setBalSaving(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_HQ_CNY:
                        //人民币活期存款余额
                        cstLblAstInfo.setBalHqCny(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_HQ_RMB:
                        //外币活期存款余额(折人民币)
                        cstLblAstInfo.setBalHqRmb(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_DQ_CNY:
                        //人民币定期期存款余额
                        cstLblAstInfo.setBalDqCny(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_DQ_RMB:
                        //外币定期存款余额(折人民币)
                        cstLblAstInfo.setBalDqRmb(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_CARD_GJJ:
                        //公积金借记卡余额
                        cstLblAstInfo.setBalCardGjj(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_CHECK:
                        //支票余额
                        cstLblAstInfo.setBalCheck(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_VOUCHER_BOND:
                        //凭证式国债余额
                        cstLblAstInfo.setBalVoucherBond(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_SAVING_BOND:
                       //储蓄式国债余额
                        cstLblAstInfo.setBalSavingBond(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_BOOKING_BOND:
                        //记账式国债余额
                        cstLblAstInfo.setBalBookingBond(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND:
                        //基金余额
                        cstLblAstInfo.setBalFund(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_PGX:
                        //偏股型基金余额
                        cstLblAstInfo.setBalFundPgx(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_ZQX:
                        //债券型基金余额
                        cstLblAstInfo.setBalFundZqx(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_HBX:
                        //货币型基金余额
                        cstLblAstInfo.setBalFundHbx(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_YDD:
                        //一对多基金余额
                        cstLblAstInfo.setBalFundYdd(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_OTH:
                        //其他基金余额
                        cstLblAstInfo.setBalFundOth(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_INS:
                        //保险余额
                        cstLblAstInfo.setBalIns(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_V_ACCOUNT:
                        //V账户余额
                        cstLblAstInfo.setBalVAccount(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD:
                        //理财余额
                        cstLblAstInfo.setBalXpad(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_CNY:
                        //人民币理财余额
                        cstLblAstInfo.setBalXpadCny(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_RMB:
                        //外币理财余额（折人民币）
                        cstLblAstInfo.setBalXpadRmb(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_BN:
                        //表内理财余额
                        cstLblAstInfo.setBalXpadBn(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_BW:
                        //表外理财余额
                        cstLblAstInfo.setBalXpadBw(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_H:
                        //持有高收益理财产品余额
                        cstLblAstInfo.setBalXpadH(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_M:
                        //持有中收益理财产品余额
                        cstLblAstInfo.setBalXpadM(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_L:
                        //持有低收益理财产品余额
                        cstLblAstInfo.setBalXpadL(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_XPAD_NONLVL:
                        //持有收益类型未分类的理财产品余额
                        cstLblAstInfo.setBalXpadNonlvl(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_GOLD:
                        //纸黄金余额
                        cstLblAstInfo.setBalGold(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_SILVER:
                        //纸白银余额
                        cstLblAstInfo.setBalSilver(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_JOIN_XPAD:
                        //汇聚理财余额
                        cstLblAstInfo.setBalJoinXpad(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_FUND_XPAD:
                        //通过基金系统销售的理财余额
                        cstLblAstInfo.setBalFundXpad(resultMap.get(authorizationFiel));
                        break;
                    case Constants.CST_LBL_AST_QUERY_MODULE_BAL_TPCC:
                        cstLblAstInfo.setBalTpcc(resultMap.get(authorizationFiel));
                        break;

                    default:
                        break;
                }
            }
        }
        String ctfNo = resultMap.get(Constants.CST_LBL_AST_QUERY_MODULE_NEW_CTF_NO);
        if (StringUtils.isNotBlank(ctfNo)) {
            cstLblAstInfo.setNewCtfNo(ctfNo);
        }
        return cstLblAstInfo;
    }

    private Result[] getResultArray(String tableName, List<String> ctfNoList) {
        Configuration conf = hbaseTemplate.getConfiguration();
        Connection connection = null;
        try {
            List<Get> getList = new ArrayList<>();
            connection = ConnectionFactory.createConnection(conf);
            Table table = connection.getTable(TableName.valueOf(tableName));
            for (String ctfNo : ctfNoList) {//把rowkey加到get里，再把get装到list中
                if (StringUtils.isNotBlank(ctfNo)) {
                    Get get = new Get(Bytes.toBytes(ctfNo));
                    getList.add(get);
                }
            }
            return table.get(getList);//直接查getList<Get>
        } catch (IOException ioException) {
            ioException.printStackTrace();
            logger.info("[getResultArray] get result error");
            return null;
        } finally {
            {
                try {
                    if (connection != null) {
                        connection.close();
                    }
                } catch (IOException e) {
                    logger.info("[getResultArray] shutdown Connection error");
                }
            }
        }

    }
}



